﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Threading.Tasks;
using Marmat.Foundation;
using Marmat.FrameWork;
using Marmat.Template.WinForm;
using Microsoft.Extensions.DependencyInjection;
using 测试项目.TestDemo;

namespace 测试项目
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddWinFormTemplate(); //注册Marmat.WinForm库中的内置模板
            services.AddTransient<ILoginForm, LoginForm>();//注册登录窗体
            services.AddTransient<Marmat.Foundation.ILogin, Login>();//注册登录的实现过程
            services.AddTransient<ILoadUserSetting, LoadUserSetting>();//注册加载用户的设置信息
            services.AddSingleton<IMainForm, MyMainForm>();//注册主窗体
            services.AddTransient<IAdvRelationProvider<TestDemoEntity>, TestFirstDemoCommand>();

            services.AddTransient<IUserManager, UserManagement>();
            services.AddTransient<IOrganization, Organization>();
            services.AddTransient<IPermissionManager, PermissionManager>();
            services.AddTransient<IPermissionMenuManager, PermissionMenuManager>();
            services.AddTransient<IPermissionManagerForm, Marmat.Template.WinForm.PermissionManagerForm>();
            services.AddTransient<ISelectionUserForm, Marmat.Template.WinForm.SelectionUserForm>();

            services.AddTransient<IDataDictionary, DataDictionary>();
            services.AddTransient<IDataDictionaryManager, DataDictionaryManager>();
            services.AddTransient<IDataDictionaryManagerForm, Marmat.Template.WinForm.DataDictionaryForm>();
            services.AddTransient<IAlert, Marmat.Template.WinForm.Alert>();
            services.AddTransient<Marmat.Foundation.IEditFormPanelContainer, EditFormPanelContainer>();
            services.AddTransient<Marmat.Foundation.IEditFormPanel, UserControl2>();
            services.AddTransient<Marmat.Foundation.IEditFormPanel, UserControl3>();
            services.AddTransient<Marmat.Foundation.IChangePassword, ChangePassword>();

            services.RegisterModel<TestFirstDemoManagement>();
            services.AddTransient<IMenuItemBuilder, MenuItemBuilder>();
            //services.EnabledAutoUpgrade("https://localhost:6069");
            Marmat.Common.Http.HttpFactory.ConfigureHttpApiConfig(options =>
            {
                options.HttpHost = new Uri("http://ludun.3mzz.cn:6061/");
                options.AddJwtBearer();
                options.EnableServerCertificateValidation = false;
            });

            services.UseDeveloper();
            //services.AddSingleton<IMainForm, MainMultilevelForm>();//注册主窗体
            //services.AddSingleton<IUpgrade, UpgradeClient>();//注册自动升级的规则
        }
    }
}
